extends Node2D

const MAX_RADIUS = 100#攻击半径

@onready var hit_box_componcent = $HitboxComponent

var base_rotation = Vector2.ZERO#旋转角度


func _ready() -> void:
	base_rotation = Vector2.RIGHT.rotated(randf_range(0,TAU))
	var tween = create_tween()
	tween.tween_method(tween_method, 0.0, 2.0 ,3)
	tween.tween_callback(queue_free)
	pass

#随机一个角度顺时针旋转一圈
func tween_method(rotations: float) -> void:
	var current_radius = (rotations / 2) * MAX_RADIUS
	var current_dircetion = base_rotation.rotated(rotations * TAU)
	var player = self.get_tree().get_first_node_in_group("player") as Node2D
	if player == null:
		return
	self.global_position = player.global_position + (current_dircetion * current_radius)
	pass
